Ext.define("App.controller.Review", {
	extend: "Ext.app.Controller",
	requires: ["Ext.MessageBox"],
	config: {
		refs: {
			reviewCard: "#reviewCard",
            reviewList: "#reviewList",
			reviewInfo: "#reviewInfo"
        },
		
		control: {
            reviewList: {
            	itemtap: "onReviewListItemTap"
            }
		}
	},
	
	
	onReviewListItemTap: function(list, idx, el, record){
		var newsDetailStore = Ext.getStore('NewsDetail');
		var newsId = record.get('newsId');

		newsDetailStore.clearFilter();
		
		newsDetailStore.setProxy({
            type: "jsonp",
            url: "http://www.51inews.com/inewsServer/findExamNewsDetail.action?newsId=" + newsId,
            callbackKey: 'callback',
            reader: {
                type: "json",
                rootProperty: "root"
            }
        });
		newsDetailStore.load();
		if (!this.reviewInfo) {
			this.reviewInfo = Ext.widget('reviewInfo');
		}
		this.reviewInfo.config.title = record.get('title');
		this.getReviewCard().push(this.reviewInfo);
		this.reviewInfo.setStore(newsDetailStore);



//		if (!this.reviewInfo) {
//			this.reviewInfo = Ext.widget('reviewInfo');
//			this.reviewInfo.setItems(this.getDailyNewsItems(record));
//		}
//		this.reviewInfo.config.title = record.get('title');
//		this.getReviewCard().push(this.reviewInfo);
	},
	
	
	
	getDailyNewsItems: function(record){
        var subItems = [];
        Ext.data.JsonP.request({
            url: "http://www.51inews.com/inewsServer/findExamNewsDetail.action?newsId=" + record.get('newsId'),
            callbackKey: 'callback',
            success: function(data){
                return data.root;
            }
        });
    }
	
});